import tornado

from tornado.web import RequestHandler, Application, url


class RequestGetDemo(RequestHandler):
    def get(self):
        message = self.get_query_argument('message', None)
        if message:
            self.set_header("Content-Type", "text/plain")
            self.write("You wrote " + message)
        else:
            self.write('<html><body><form action="/" method="GET">'
                       '<input type="text" name="message">'
                       '<input type="submit" value="Submit">'
                       '</form></body></html>')


app = Application([
    url(r"/", RequestGetDemo),
])


def _test_get():
    """
    _test_get()
    >
    192.168.1.103:8000
    """
    app.listen(8000)
    tornado.ioloop.IOLoop.current().start()


if __name__ == '__main__':
    _test_get()
